package Demo1;

public class T10 {
    private static int result = 0;// 静态成员变量，被多个线程共享
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            for (int i = 1; i <= 100; i++) {
                result+=i;
            }
        });
        thread.start();
        thread.join();//多线程 用thread计算和  阻塞一下 最后在主线程中打印结果
        System.out.println(result);
    }
}
